<?php
require("../global.php");
require("../Phpword/PHPWord.php");
header("Content-Type: text/html; charset=utf-8");

     $sures = "select * from dzfbillmsg where zf_id = ".$_REQUEST['zf_id']." limit 1";
	 $suarr = $db->get_sql_row($sures,'mysql_fetch_assoc');   
    

	


        $PHPWord = new PHPWord();
        $section = $PHPWord->createSection(array('marginLeft'=>600, 'marginRight'=>600, 'marginTop'=>600, 'marginBottom'=>600));


		
		// Write some text
		$strtext1 = "支出证明单";
		$PHPWord->addParagraphStyle('pStyle', array('align'=>'center'));
		
		$PHPWord->addParagraphStyle('pStyler', array('align'=>'right'));
		$PHPWord->addFontStyle('rStyle', array('size'=>'24','bold'=>true));
		
		$section->addText($strtext1,'rStyle', 'pStyle');
        //$section->addTextBreak();
        $fontStyle = array('bold'=>true);
        $fsb = array('bold'=>true,'align'=>'right');
		$fvc = array('valign'=>'center');
		$fac = array('align'=>'center');
		$ccontinue = array('cellMerge' => 'continue');
		$crestart = array('cellMerge' => 'restart','valign'=>'center');
		$crestart1 = array('cellMerge' => 'restart');
		$crestart2 = array('cellMerge' => 'restart','valign'=>'center');
		
		$rcontinue = array('rowMerge' => 'continue');
		$rrestart = array('rowMerge' => 'restart','valign'=>'center');
		$PHPWord->addFontStyle('fStyle', array('bold'=>true));
		$PHPWord->addFontStyle('fStyle1', array('bold'=>true, 'marginRight'=>600));
		
		
        $rowh = '300';
		
		
		// Define table style arrays
        $styleTable = array('borderSize'=>6, 'borderColor'=>'000000', 'cellMargin'=>80);
        
       // Add table style
        
        
		$PHPWord->addTableStyle('myOwnTableStyle', $styleTable);

        $table1 = $section->addTable('myOwnTableStyle');
		$table1->addRow($rowh);
        $table1->addCell(2000,$crestart)->addText('第         号                 ','fStyle1','pStyler');
		
		$table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
		
		
		
		$table1->addRow($rowh);
		$textd = '帐页(              )'.'             '.date('Y 年 m 月 d 日 ',strtotime($suarr['begin_date']));
        
		$table1->addCell(2000,$crestart)->addText($textd,'fStyle','pStyle');
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
		
        $table1->addRow($rowh);
        $table1->addCell(2000,$fvc)->addText('摘要及用途','fStyle','pStyle');
		
		$textd = mb_convert_encoding($suarr['zf_dw'],'utf-8','GBK').''.mb_convert_encoding($suarr['zf_note'],'utf-8','GBK').' （团号）'.mb_convert_encoding($suarr['tuanno'],'utf-8','GBK').'（数量）'.mb_convert_encoding($suarr['zf_num'],'utf-8','GBK');
        $table1->addCell(500,$crestart)->addText($textd);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
		
		$table1->addRow($rowh);
        $table1->addCell(2000,$fvc)->addText('金        额','fStyle','pStyle');
        $table1->addCell(500,$crestart)->addText($suarr['zf_moeny'].'元');
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
		
		$table1->addRow($rowh);
		$textda = "
不        能   
取        得   
单        据   
原        因
		";
        $table1->addCell(2000,$fvc)->addText(trim($textda),'fStyle','pStyle');
        $table1->addCell(500,$crestart)->addText('');
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
        $table1->addCell(500,$ccontinue);
        $table1->addCell(1000,$ccontinue);
		
		$table1->addRow($rowh);
        $table1->addCell(2000,$fvc)->addText('签        署','fStyle','pStyle');
		
        $table1->addCell(500,$fvc)->addText('核准',$fontStyle);
		$table1->addCell(1000,$fvc)->addText('',$fontStyle);
		
		$table1->addCell(500,$fvc)->addText('会计',$fontStyle);
		$table1->addCell(1000,$fvc)->addText('',$fontStyle);
		
		$table1->addCell(500,$fvc)->addText('出纳',$fontStyle);
		$table1->addCell(1000,$fvc)->addText('',$fontStyle);
		
		$table1->addCell(500,$fvc)->addText('主管',$fontStyle);
		$table1->addCell(1000,$fvc)->addText('',$fontStyle);
		
		$table1->addCell(500,$fvc)->addText('验收',$fontStyle);
		$table1->addCell(1000,$fvc)->addText('',$fontStyle);
		
		$table1->addCell(500,$fvc)->addText('经手',$fontStyle);
		$table1->addCell(1000,$fvc)->addText(mb_convert_encoding($suarr['zf_no'],'utf-8','GBK'));

		
		

		





		


		// Save File
		//$filename = $orarr['begin_date'].' '.$orarr['customer_id'].$orarr['cus_name'].'('.$xlkarr['line_name'].')';
		
        $fillexml =$filename.mb_convert_encoding('支出证明单','GBK','utf-8');
		
		 header("Content-type: application/vnd.ms-word");
         header("Content-Disposition:attachment;filename=".$fillexml.".docx"); 
         header('Cache-Control: max-age=0');

        $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
       // $objWriter->save($filename);
        $objWriter->save('php://output');

?>